﻿using System;
using System.Collections.Generic;
using System.Text;

namespace daSyntaxAnalyser.SyntaxTree
{
    using daBase.Objects;

    public class ConstDefinitionElement : ResourceStringDefinitionElement
    {
        private IConstTypeElement type;

        public IConstTypeElement Type { get { return type; } set { type = value; } }

        public ConstDefinitionElement(TokenInfo Id, IConstTypeElement Type, ISyntaxTreeElement Value, List<TokenInfo> Comments)
            : base(Id, Value, Comments)
        {
            type = Type;
        }

        public override string ToString()
        {
            string result = id.Text;
            if (type != null)
                result += string.Format(":{0}", type);
            return string.Format("{0} = {1};", result, value);
        }

        protected override IEnumerator<ISyntaxTreeElement> CreateEnumerator()
        {
            if (type != null)
                yield return type;
            yield return value;
        }
    }
}
